package com.controller;

import com.bean.Sales;
import com.service.SalesService;
import com.util.PageAssistant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpSession;
import java.util.HashMap;

@Component
@Controller
public class ViewController {

    @Autowired
    private SalesService salesService;

    @RequestMapping("/")
    public String home(){
        return "login";
    }

    @RequestMapping("login")
    public String login(HttpSession session, Model model){
        model.addAttribute("msg",session.getAttribute("msg"));
        session.removeAttribute("msg");
        return "login";
    }

    @RequestMapping("main")
    public String main(HttpSession session, Model model){
        model.addAttribute("loginInfo",session.getAttribute("loginInfo"));
        return "page/mains";
    }


   @RequestMapping("f")
    public String films(HttpSession session,Model model){
        model.addAttribute("movieList",session.getAttribute("movieList"));
        model.addAttribute("cinemaList",session.getAttribute("cinemaList"));
        if(session.getAttribute("msg") != null){
            model.addAttribute("msg",session.getAttribute("msg"));
            session.removeAttribute("msg");
        }
        return "page/films/filmsAdd";
    }





}
